package com.yunyao.dao.service.bamu.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunyao.common.constant.enums.DataDeletedStatus;
import com.yunyao.dao.model.BamuPurchaseApplyMaterial;
import com.yunyao.dao.mapper.BamuPurchaseApplyMaterialMapper;
import com.yunyao.dao.service.bamu.IBamuPurchaseApplyMaterialService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 合同材料表 服务实现类
 * </p>
 *
 * @author xingjishuai
 * @since 2024-07-02
 */
@Service
public class BamuPurchaseApplyMaterialServiceImpl extends ServiceImpl<BamuPurchaseApplyMaterialMapper, BamuPurchaseApplyMaterial> implements IBamuPurchaseApplyMaterialService {

    @Override
    public BamuPurchaseApplyMaterial getTotalByOrderId(String orderId) {
        return baseMapper.selectTotalByOrderId(orderId);
    }

    @Override
    public List<BamuPurchaseApplyMaterial> getMaterialListByOrderId(String orderId) {
        LambdaQueryWrapper<BamuPurchaseApplyMaterial> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BamuPurchaseApplyMaterial::getPurchaseApplyId, orderId).eq(BamuPurchaseApplyMaterial::getIsDeleted, DataDeletedStatus.NO.getType());
        return baseMapper.selectList(wrapper);
    }

    @Override
    public BigDecimal getSumTaxTotalPriceByPurchaseApplyId(String purchaseApplyId) {
        return baseMapper.getSumTaxTotalPriceByPurchaseApplyId(purchaseApplyId);
    }

    @Override
    public BigDecimal getSumNoTaxTotalPriceByPurchaseApplyId(String purchaseApplyId) {
        return baseMapper.getSumNoTaxTotalPriceByPurchaseApplyId(purchaseApplyId);
    }
}
